---
import { locales } from '../i18n/config';
import { getLangFromUrl } from '../i18n/utils';

const currLang = getLangFromUrl(Astro.url);
---


<select class="inline-flex items-center hover:bg-gray-light py-1 px-3 focus:outline-none rounded text-base mt-4 md:mt-0 mx-3" onchange="self.location.href=options[selectedIndex].value">
  {Object.entries(locales).map(([lang, label]) => (
    <option value={`/${lang}`} selected = { lang == currLang && `selected` }>
      <a href={`/${lang}/`}>{label}</a>
    </option>
  ))}
</select>